package com.oop.example.gui;

/**
 * @author SalAA
 */
public enum EStatus {

    ALL("ALL", -1),
    NEW("NEW", 0),
    PARSED("PARSED", 1),
    WARN("WARN", 2),
    ERROR("ERROR", 3);
    //---
    private String name = "";
    private int id = 0;

    public static EStatus byID(int id) {
        for (EStatus st : values()) {
            if (st.getId() == id) {
                return st;
            }
        }
        throw new IllegalArgumentException("no status id=" + id);
    }

    public static EStatus byName(String name) {
        for (EStatus st : values()) {
            if (st.getName().equalsIgnoreCase(name)) {
                return st;
            }
        }
        throw new IllegalArgumentException("no status name=" + name);
    }

    private EStatus(String name, int id) {
        this.name = name;
        this.id = id;
    }

    public int getId() {
        return id;
    }

    public String getName() {
        return name;
    }
}
